/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PanelVerSocio.java
 *
 * Created on Apr 20, 2011, 12:23:51 PM
 */

package forms;

import beans.Socio;
import java.awt.Color;
import java.awt.Component;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

/**
 *
 * @author nMoncho
 */
public class PanelVerSocio extends javax.swing.JPanel implements ListCellRenderer{

    private final static Color unselectedTextBackground = new Color(242,242,189);
    private final static Color selectedTextBackground = new Color(115,164,209);
    private final static Color unselectedBackground = new Color(214,217,223);
    private final static Color selectedBackground = new Color(57,105,138);
    /** Creates new form PanelVerSocio */
    public PanelVerSocio() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        labelLegajo = new javax.swing.JLabel();
        textLegajo = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        textApellidoNombre = new javax.swing.JTextField();
        labelBoliche = new javax.swing.JLabel();
        textBoliche = new javax.swing.JTextField();
        labelRazon = new javax.swing.JLabel();
        textRazon = new javax.swing.JTextField();
        labelPuntaje = new javax.swing.JLabel();
        textPuntaje = new javax.swing.JTextField();

        setBackground(new java.awt.Color(255, 255, 255));
        setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        labelLegajo.setText("Legajo:");

        textLegajo.setBorder(null);

        jLabel1.setText("Apellido y Nombre:");

        textApellidoNombre.setBorder(null);

        labelBoliche.setText("Boliche:");

        textBoliche.setBorder(null);

        labelRazon.setText("Motivo Socio:");

        textRazon.setBorder(null);

        labelPuntaje.setText("Puntaje Total:");

        textPuntaje.setBorder(null);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(labelLegajo)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textLegajo, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(labelBoliche)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textBoliche, javax.swing.GroupLayout.DEFAULT_SIZE, 102, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textApellidoNombre, javax.swing.GroupLayout.DEFAULT_SIZE, 188, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(labelRazon)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textRazon, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(labelPuntaje)
                        .addGap(10, 10, 10)
                        .addComponent(textPuntaje, javax.swing.GroupLayout.DEFAULT_SIZE, 33, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelLegajo)
                    .addComponent(textLegajo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelBoliche)
                    .addComponent(textBoliche, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(textApellidoNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelRazon)
                    .addComponent(textRazon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(textPuntaje, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelPuntaje))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel labelBoliche;
    private javax.swing.JLabel labelLegajo;
    private javax.swing.JLabel labelPuntaje;
    private javax.swing.JLabel labelRazon;
    private javax.swing.JTextField textApellidoNombre;
    private javax.swing.JTextField textBoliche;
    private javax.swing.JTextField textLegajo;
    private javax.swing.JTextField textPuntaje;
    private javax.swing.JTextField textRazon;
    // End of variables declaration//GEN-END:variables

    @Override
    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
        Socio socio = (Socio)value;
        textLegajo.setText(socio.getLegajo());
        textBoliche.setText(socio.getBoliche().getNombre());
        textApellidoNombre.setText(socio.getApellido()+" "+socio.getNombre());
        textRazon.setText(socio.getRazonSocio());
        textPuntaje.setText(socio.getPuntajeTotal() != null ? socio.getPuntajeTotal().toString() : "0");

        Color background = (isSelected ? selectedBackground : unselectedBackground);
        this.setBackground(background);

        background = (isSelected ? selectedTextBackground : unselectedTextBackground);
        textLegajo.setBackground(background);
        textBoliche.setBackground(background);
        textApellidoNombre.setBackground(background);
        textRazon.setBackground(background);
        textPuntaje.setBackground(background);

        return this;
        
    }

}
